<template>
	<view class="mine">
		<image class="bg" mode="widthFix"
			src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/20240131224214128592.png">
		</image>
		<view class="user" @click="gologin">
			<image class="avatar" :src="info.avatar||'https://video.file.zhuochengyun.com/bwc/uploads/20240207/20240207204602905198.jpg'"></image>
			<view class="info">
				<view class="name">{{info.nickname||'未登录'}}
				<!-- 	<view class="goGet" @click.stop="navTo('/pages/tixian/index','navigatorTo')">
						<image class="icon-pic" src="https://video.file.zhuochengyun.com/bwc/uploads/20240207/20240207203857956275.png"></image>
						去提现
					</view> -->
				</view>
				<view class="tel">{{info.mobile}}</view>
			</view>
		</view>
		<view class="list">
			<view class="li">
				<view class="label">已省</view>
				<view class="value">{{ info.total_rebate || '0.00' }}</view>
			</view>
			<view class="li">
				<view class="label">待入账</view>
				<view class="value">{{ info.recorded || '0.00' }}</view>
			</view>
			<view class="li">
				<view class="label">余额</view>
				<view class="value">{{ info.able_rebate || '0.00' }}</view>
			</view>
		</view>
		<view class="vip">
			<image class="level" src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/2024013122573133439.png">
			</image>
			<view class="vip-name">尊享会员</view>
			<view class="vip-tip">享超多会员特权</view>
			<view class="vip-btn" @click="navTo('/pages/member/index','switchTab')">立即开通</view>
		</view>
		<view class="team">
			<view class="team-title">我的团队（{{ team.total_num || '0' }}人）</view>
			<view class="team-new">今日新增{{ team.today_num || '0' }}人</view>
			<view class="team-list">
				<view class="team-li">
					<view class="team-name">今日收益（元）</view>
					<view class="team-val">
						<text>￥</text>
						{{ team.today_commission || '0.00' }}
					</view>
				</view>
				<view class="team-li">
					<view class="team-name">累计收益（元）</view>
					<view class="team-val">
						<text>￥</text>
						{{ info.total_commission || '0.00' }}
					</view>
				</view>
			</view>
		</view>
		<view class="service">
			<view class="service-title">相关服务</view>
			<view class="service-list">
				<!-- <navigator url="/pages/payCode/payCode" class="item">
					<view class="service-li">
						<image class="service-img" style="width: 58rpx;height:44rpx ;"
							src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/20240131231230904801.png">
						</image>
						<view class="service-txt">收款管理</view>
					</view>
				</navigator> -->
				<navigator url="/pages/changePhone/changePhone" class="item">
					<view class="service-li">
						<image class="service-img" style="width: 43rpx;height:53rpx ;"
							src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/20240131231255993089.png">
						</image>
						<view class="service-txt">{{ info.mobile ? '更换手机' : '绑定手机' }}</view>
					</view>
				</navigator>
				<navigator url="/pages/shareCode/shareCode" open-type="navigate" class="item">
					<view class="service-li">
						<image class="service-img" style="width: 55rpx;height:53rpx ;"
							src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/20240131231312419856.png">
						</image>
						<view class="service-txt">分享赚钱</view>
					</view>
				</navigator>
				<!-- <navigator url="/pages/settlement/index" class="item">
					<view class="service-li">
						<image class="service-img" style="width: 59rpx;height:47rpx ;"
							src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/20240131231457305106.png">
						</image>
						<view class="service-txt">商家入驻</view>
					</view>
				</navigator> -->
			</view>
		</view>
		<view class="other">
			<view class="other-title">其他</view>
			<navigator url="/pages/problemList/problemList" class="item">
				<view class="other-li">
					<image class="other-img"
						src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/20240131231955628844.png"></image>
					<view class="other-txt">帮助中心</view>
					<image class="other-righticon" src="../../static/img/right.png"></image>
				</view>
			</navigator>
			<navigator url="/pages/bugFeedback/index" class="item">
				<view class="other-li">
					<image class="other-img"
						src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/20240131231854584877.png"></image>
					<view class="other-txt">问题反馈</view>
					<image class="other-righticon" src="../../static/img/right.png"></image>
				</view>
			</navigator>
		<!-- 	<navigator url="/pages/feedback/feedback" class="item">
				<view class="other-li">
					<image class="other-img"
						src="https://video.file.zhuochengyun.com/bwc/uploads/20240131/20240131232031985719.png"></image>
					<view class="other-txt">投诉建议</view>
				<image class="other-righticon" src="../../static/img/right.png"></image>
				</view>
			</navigator> -->
		</view>
		<view class="logout" @click="logout">退出登录</view>
	</view>
</template>
<script>
	import {
		getUserIndex,
		logout,
		getMobile
	} from '../../apirequest/api.js';
	export default {
		data() {
			return {
				vip: {},
				info: {},
				team: {},
				share: {}
			}
		},
		onLoad() {
			this.loadData()
		},
		methods: {
			getphonenumber(e){
			
			},
			gologin(){
				const openid = uni.getStorageSync('openid')
				if(!openid) {
					uni.navigateTo({
						url:'/pages/wechatLogin/wechatLogin'
					})
				}
			},
			navTo(url, type) {
				if (type == 'switchTab') {
					uni.switchTab({
						url
					})
				}else{
					uni.navigateTo({
						url
					})
				}
			},
			//退出登录
			logout() {
				const that = this;
				uni.showModal({
					title: '提示',
					content: '确定退出登录吗?',
					success(ret) {
						if (ret.confirm) {
							logout({}).then((res) => {
								if (res.code == 1) {
									uni.showToast({
										title: res.msg,
										icon: 'success'
									});
									setTimeout(function() {
										uni.clearStorage();
										uni.switchTab({
											url: '/pages/index/index'
										})
									}, 1000);
								} else {
									uni.showToast({
										title: res.msg,
										icon: 'error'
									})
								}
							})
						}
						if (ret.cancel) {

						}
					}
				});
			},
			//获取数据
			loadData() {
				const openid = uni.getStorageSync('openid')
				if(!openid) return false
				getUserIndex({}).then((res) => {
					console.log('res', res)
					if (res.code == 1) {
						this.vip = res.data.vip;
						this.info = res.data.info;
						this.team = res.data.team;
						this.share = res.data.share;
					} else {
						uni.showToast({
							title: res.msg,
							icon: "error"
						})
						setTimeout(function() {
							uni.navigateBack({
								delta: 0
							});
						}, 1000)
					}
				}).catch(err => {
					console.log(err)
				})

			},
		}
	}
</script>
<style scoped lang="scss">
	.mine {
		position: relative;
		padding-top: 160rpx;
		background-color: #f4f4f4;
		padding-bottom: 100rpx;

		.bg {
			width: 100%;
			position: absolute;
			left: 0;
			top: 0;
			z-index: 1;
		}

		.user {
			padding: 0 40rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			position: relative;
			z-index: 2;

			.avatar {
				width: 133rpx;
				height: 133rpx;
				border-radius: 50%;
				border: 6rpx solid rgba(255, 255, 255, .3);
				margin-right: 20rpx;
			}

			.info {
				.name {
					font-size: 39rpx;
					font-family: SourceHanSansCN;
					font-weight: bold;
					color: #FFFFFF;
					display: flex;
					align-items: center;

					.goGet {
						font-size: 22rpx;
						font-family: PingFang SC;
						color: #F78266;
						background-color: #fff;
						margin-left: 50rpx;
						padding: 0 10rpx 0 0;
						border-radius: 20rpx;
						font-size: 24rpx;
						display: flex;
						font-weight: normal;
						align-items: center;
						.icon-pic{
							background-color: #F88769;
							width: 35rpx;
							height: 35rpx;
							border-radius: 50%;
							margin-right: 5rpx;
						}
					}
				}

				.tel {
					font-size: 29rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #FFFFFF;
				}
			}
		}

		.list {
			position: relative;
			z-index: 2;
			display: flex;
			align-items: center;
			justify-content: space-around;
			margin-top: 20rpx;

			.li {
				flex: 1;
				text-align: center;

				.label {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
				}

				.value {
					margin-top: 10rpx;
					font-size: 39rpx;
					font-family: Source Han Sans CN;
					font-weight: bold;
					color: #FFFFFF;
				}
			}
		}

		.vip {
			width: 710rpx;
			height: 92rpx;
			background: #fff;
			border-radius: 17rpx;
			margin: 40rpx auto 20rpx;

			position: relative;
			z-index: 2;
			display: flex;
			justify-content: center;
			align-items: center;

			.level {
				width: 61rpx;
				height: 43rpx;
				margin-right: 20rpx;
			}

			.vip-name {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #6F3904;
				margin-right: 40rpx;
			}

			.vip-tip {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #6F3904;
				background: linear-gradient(0deg, #C16822 0%, #C9994B 52.587890625%, #A45E1A 100%);
				-webkit-background-clip: text;
				-webkit-text-fill-color: transparent;
				margin-right: 80rpx;
			}

			.vip-btn {
				background: linear-gradient(0deg, #F7D398, #F3D6A7, #E2BA78);
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #311C0D;
				padding: 12rpx 26rpx;
				border-radius: 40rpx;
			}
		}

		.team {
			width: 710rpx;
			background: #FFFFFF;
			border-radius: 17rpx;
			margin: 20rpx auto;
			position: relative;

			.team-title {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				padding: 24rpx;
				box-sizing: border-box;

			}

			.team-new {
				font-size: 24rpx;
				font-family: PingFang SC;
				color: #333333;
				opacity: 0.62;
				position: absolute;
				right: 24rpx;
				top: 28rpx;
			}

			.team-list {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 24rpx 24rpx;
				box-sizing: border-box;

				.team-li {
					width: 314rpx;
					height: 147rpx;
					background: #fffaf7;
					border-radius: 10rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					flex-direction: column;

					.team-name {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #F96505;

					}

					.team-val {
						font-size: 24rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #F96505;
						text-align: center;
						margin-top: 20rpx;

						text {}


					}
				}
			}
		}

		.service {
			width: 710rpx;
			height: 244rpx;
			background: #FFFFFF;
			border-radius: 17rpx;
			padding: 24rpx;
			box-sizing: border-box;
			margin: 20rpx auto;

			.service-title {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				border-bottom: 1rpx solid #f4f4f4;
				padding-bottom: 24rpx;

			}

			.service-list {
				display: flex;
				align-items: center;
				justify-content: space-around;

				.service-li {
					text-align: center;
					padding: 24rpx 0 0;

					.service-img {}

					.service-txt {
						font-size: 24rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #333333;
						margin-top: 10rpx;
					}
				}
			}
		}

		.other {
			width: 710rpx;
			background: #FFFFFF;
			border-radius: 17rpx;
			padding: 24rpx 24rpx 0;
			box-sizing: border-box;
			margin: 20rpx auto;

			.other-title {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				padding-bottom: 24rpx;

			}

			.other-li {
				display: flex;
				align-items: center;
				padding: 20rpx 12rpx;
				border-top: 1rpx solid #f4f4f4;
				position: relative;

				.other-img {
					width: 40rpx;
					height: 40rpx;
					margin-right: 20rpx;
				}

				.other-txt {
					font-size: 24rpx;
					color: #333;

				}

				.other-righticon {
					width: 34rpx;
					height: 34rpx;
					position: absolute;
					right: 12rpx;
					top: 50%;
					transform: translateY(-50%);
					font-size: 20rpx;
					color: #666;
				}
			}
		}

		.logout {
			width: 614rpx;
			height: 92rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
			line-height: 92rpx;
			background: #3C2816;
			border-radius: 46rpx;
			margin: 40rpx auto 0;
			text-align: center;
		}
	}
</style>